clear all
set more off, perm
set mem 10000000
set matsize 10000
version 13

****************************************************************** 
*** Table and figures for JPE revisions: benefit-cost analysis ***
****************************************************************** 

** Set file paths
do "$path_code/paths.do"

** Set graph scheme
cd "$path/code/analyze"
set scheme fb, perm

********************************************************************************
********************************************************************************

** Table 8: ROI table using expenditure estimates
{
cap file close tablewrite
use "$results/roi_results_expenditure_bootstraps.dta", clear

local fc = "hi"
local g = "g"

count if ROI20_hours_5_`fc'_300`g'>0
local pos1_1 = string(r(N)/_N,"%9.3f")
count if ROI20_hours_10_`fc'_300`g'>0
local pos2_1 = string(r(N)/_N,"%9.3f")
count if ROI20_hours_15_`fc'_300`g'>0
local pos3_1 = string(r(N)/_N,"%9.3f")

count if ROI20_lights_5_`fc'_300`g'>0
local pos1_2 = string(r(N)/_N,"%9.3f")
count if ROI20_lights_10_`fc'_300`g'>0
local pos2_2 = string(r(N)/_N,"%9.3f")
count if ROI20_lights_15_`fc'_300`g'>0
local pos3_2 = string(r(N)/_N,"%9.3f")

count if ROI20_nss1_5_`fc'_1000`g'>0
local pos1_3 = string(r(N)/_N,"%9.3f")
count if ROI20_nss1_10_`fc'_1000`g'>0
local pos2_3 = string(r(N)/_N,"%9.3f")
count if ROI20_nss1_15_`fc'_1000`g'>0
local pos3_3 = string(r(N)/_N,"%9.3f")

count if ROI20_nss2_5_`fc'_2000`g'>0
local pos1_4 = string(r(N)/_N,"%9.3f")
count if ROI20_nss2_10_`fc'_2000`g'>0
local pos2_4 = string(r(N)/_N,"%9.3f")
count if ROI20_nss2_15_`fc'_2000`g'>0
local pos3_4 = string(r(N)/_N,"%9.3f")


   // MAKE TABLE
file open tablewrite using "$textab/table_roi_expenditure.tex", write text replace
 
file write tablewrite "\begin{table}[p]\centering" _n
file write tablewrite "\caption{Return on investment from electrification, using consumption expenditure}" _n
file write tablewrite "\label{tab:roi_expenditure}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\small" _n
file write tablewrite "\begin{tabular}{cccccccccc}" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "& \multicolumn{4}{c}{\$\Pr\big(\text{20-year ROI} > 0\big)\$, by village population} \\ " _n
file write tablewrite "[0.15em]" _n
file write tablewrite "& 300 & 300 & 1000 & 2000 \\" _n
file write tablewrite "\cline{2-5}" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "\underline{Discount rate} \\" _n
file write tablewrite "[0.15em]" _n
file write tablewrite "\$r = 0.05\$ & $`pos1_1'$ & $`pos1_2'$ & $`pos1_3'$ & $`pos1_4'$ \\" _n
file write tablewrite "\$r = 0.10\$ & $`pos2_1'$ & $`pos2_2'$ & $`pos2_3'$ & $`pos2_4'$ \\" _n
file write tablewrite "\$r = 0.15\$ & $`pos3_1'$ & $`pos3_2'$ & $`pos3_3'$ & $`pos3_4'$ \\" _n
file write tablewrite "[1em]" _n
file write tablewrite "\multicolumn{1}{l}{Expenditure/capita}    & SHRUG & SHRUG & NSS & NSS\\" _n
file write tablewrite "\multicolumn{1}{l}{Endog.\ variable} & Hours of power & Brightness & " _n
file write tablewrite "$ \mathbf{1}\big[\text{HH elec}>0\big] $  & $ \mathbf{1}\big[\text{HH elec}>0\big] $ \\" _n
file write tablewrite "\multicolumn{1}{l}{Instrument} & 300-person RD & 300-person RD & 1st-wave district  & 1st-wave district \\" _n
file write tablewrite "\multicolumn{1}{l}{Estimation sample} & RD bandwidth & RD bandwidth & Quintile 1 & Quintiles 2--5 \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\end{tabular}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\caption*{\scriptsize Note. --- " _n
file write tablewrite "We simulate expenditure benefits using our results from Columns (1) and (3) of Table \ref{tab:rd_fuzzy_shrug}, " _n
file write tablewrite "and from  Columns (2)--(3) of Table \ref{tab:nss_2sls}. We rescale fuzzy RD estimates by 10 " _n
file write tablewrite "(for hours of commercial power) and 2.6 (for nighttime brightness), and convert all four estimates to annual " _n
file write tablewrite "expenditures per capita in 2010 rupees. Then, we make 10,000 draws from each rescaled sampling " _n
file write tablewrite "distribution (see Appendix Figure \ref*{fig:expenditure_sampling_dists}), " _n
file write tablewrite "and calculate the 20-year discounted sum of expenditure changes for villages of 300, 1000, or 2000 people. " _n
file write tablewrite "We assume a constant flow of annual benefits in the village, applying annual " _n
file write tablewrite "population growth rates from the 2001--2011 Census. " _n
file write tablewrite "Finally, we subtract upfront fixed and variable costs of electrification. Following " _n
file write tablewrite "\citeauthor{banerjee_power_2014} (\citeyear{banerjee_power_2014}, p.\ 51), we assume  " _n
file write tablewrite "fixed costs of Rs 1.8 million per village and variable costs of Rs 2,200 per household," _n
file write tablewrite "inflating from 2008 to 2010 rupees." _n
file write tablewrite "Appendix Table \ref*{tab:roi_expenditure_sens} repeats these simulations under alternative fixed " _n
file write tablewrite "costs and without population growth. " _n
file write tablewrite "}" _n
file write tablewrite "\end{table}" _n

file close tablewrite

}

********************************************************************************
********************************************************************************

** Table 9: IRR table using cosumer surplus estimates
{
cap file close tablewrite
use "$results/roi_results_cs_irr.dta", clear
keep if hh_size==5
keep if round(elast,0.001)==0.62
keep if fc=="hi"

gen row = .
replace row = 1 if inlist(kwh_var,"q1","q25")		  & fc=="hi" & pop_growth==0 & kwh_growth_scenario=="0"    & exp_growth=="none"	
replace row = 2 if inlist(kwh_var,"q1","q25") 		  & fc=="hi" & pop_growth>0  & kwh_growth_scenario=="0"    & exp_growth=="none"	
replace row = 3 if inlist(kwh_var,"q1","q25") 		  & fc=="hi" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="none"	
replace row = 4 if inlist(kwh_var,"pop_exp_shares")   & fc=="hi" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="none"
replace row = 5 if inlist(kwh_var,"pop_exp_shares")   & fc=="hi" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="nss"	
replace row = 6 if inlist(kwh_var,"pop_exp_shares")   & fc=="hi" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="adhoc"	
replace row = 7 if inlist(kwh_var,"q1_hrs","q25_hrs") & fc=="hi" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="none"	
keep if row!=.
sort row pop
unique row pop
assert r(unique)==r(N)

	// round IRRs up
gen IRR = round(irr+.00001,0.01)	

	// create unified population growth variable
gen POP_GROWTH = "Yes" if pop_growth>0

	// create unified kwh_var 
gen KWH_VAR = kwh_var
replace KWH_VAR = "q1/q25" if inlist(kwh_var,"q1","q25")
replace KWH_VAR = "q1/q25 hrs" if inlist(kwh_var,"q1_hrs","q25_hrs")

	// reshape to construct table
reshape wide kwh_var kwh_mean pop_growth irr IRR, i(row) j(pop)
sort row

	// locals for table
forvalues r = 1/7 {

	if KWH_VAR[`r']=="q1/q25" {
	    local kwh`r' = "Q1 vs.\ Q25 splits"
	}
	else if KWH_VAR[`r']=="pop_exp_shares" {
	    local kwh`r' = "Expenditure quartile splits"
	}
	else if KWH_VAR[`r']=="q1/q25 hrs" {
	    local kwh`r' = "\$\begin{matrix}\text{Q1 vs.\ Q25 splits, districts} \\ \text{~~with high power quality}\end{matrix}\$"
	}

	if POP_GROWTH[`r']=="" & kwh_growth_scenario[`r']=="0" & exp_growth[`r']=="none" {
	    local scenario`r' = "No population or kWh growth"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0" & exp_growth[`r']=="none" {
	    local scenario`r' = "No kWh growth"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0.03" & exp_growth[`r']=="none" {
	    local scenario`r' = "Preferred"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0.03" & exp_growth[`r']=="nss" {
	    local scenario`r' = "NSS expenditure growth"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0.03" & exp_growth[`r']=="adhoc" {
	    local scenario`r' = "3\% expenditure growth"
	}

	foreach pop in 300 1000 2000 {
	    local irr`pop'_`r' = string(IRR`pop'[`r']*100,"%9.0f") + "\%"
		if "`irr`pop'_`r''"=="-1\%" {
		    local irr`pop'_`r' = "--"
		}
	}
}	
	
	
   // MAKE TABLE
file open tablewrite using "$textab/table_irr_cs.tex", write text replace
 
file write tablewrite "\begin{table}[p]\centering" _n
file write tablewrite "\caption{Internal rate of return from electrification, using consumer surplus}" _n
file write tablewrite "\label{tab:irr_cs}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\small" _n
file write tablewrite "\begin{tabular}{lccccccccc}" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "&&& \multicolumn{3}{c}{IRRs by village population} \\ " _n
file write tablewrite "\cline{4-6}" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "\multicolumn{1}{c}{\$\begin{matrix}\text{First-stage NSS estimates~~}\end{matrix}\$} " _n
file write tablewrite "& Scenario " _n 
file write tablewrite "&~& ~~300~~ & ~~1000~~ & ~~2000~~ \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite " " _n
file write tablewrite "`kwh1' & `scenario1' && `irr300_1' & `irr1000_1' & `irr2000_1' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh2' & `scenario2' && `irr300_2' & `irr1000_2' & `irr2000_2' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "\bf `kwh3' & \bf `scenario3' && \bf `irr300_3' & \bf `irr1000_3' & \bf `irr2000_3' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh4' & `scenario4' && `irr300_4' & `irr1000_4' & `irr2000_4' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh5' & `scenario5' && `irr300_5' & `irr1000_5' & `irr2000_5' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh6' & `scenario6' && `irr300_6' & `irr1000_6' & `irr2000_6' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh7' & `scenario7' && `irr300_7' & `irr1000_7' & `irr2000_7' \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\end{tabular}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\caption*{\scriptsize Note. --- " _n
file write tablewrite "Each row calculates internal rates of return from electrifying all households in villages of " _n
file write tablewrite "300, 1000, and 2000 people. We use econometric estimates to calculate assumed kWh per newly " _n
file write tablewrite "electrified household, dividing first-stage kWh/month estimates by first-stage " _n
file write tablewrite "extensive-margin estimates. Rows 1--3 use Columns (2) and (4) from Appendix Tables " _n
file write tablewrite "\ref*{tab:nss_first_stage_q1}--\ref*{tab:nss_first_stage_q25}; rows 4--6 use estimates from " _n
file write tablewrite "Table \ref*{tab:nss_first_stage_by_exp_quartile} weighted by household expenditure shares for " _n
file write tablewrite "NSS villages of each size; row 7 uses Columns (3)--(6) of Appendix Table \ref*{tab:nss_fs_hours}. " _n
file write tablewrite "Using these consumption levels, we apply the methodology of \textcite{lee_experimental_2020} " _n
file write tablewrite "to calculate consumer surplus per household. We assume linear demand, a retail electricity price " _n
file write tablewrite "of Rs 2.64 per kWh (the 2010 NSS median price), and a rural electricity demand elasticity " _n
file write tablewrite "of 0.62 (\textcite{burgess_demand_2020}; \textcite{mahadevan_price_2020} finds a similar "
file write tablewrite "rural residential elasticity of 0.56). We calculate IRRs by taking a 20-year discounted sum of " _n
file write tablewrite "consumer surplus in the village, using the same cost assumptions as Table \ref{tab:roi_expenditure} " _n
file write tablewrite "(see notes under Table \ref{tab:roi_expenditure} for details.) " _n
file write tablewrite "Our preferred scenarios apply annual population growth rates from the 2001--2011 Census, and  " _n
file write tablewrite "3\% annual growth in electricity consumption. In rows 1--2 and 7, electrification " _n
file write tablewrite "decreases welfare for 300-person villages even with a 0\% discount rate. " _n
file write tablewrite "Appendix Table \ref*{tab:irr_cs_fcost_lo} repeats these" _n
file write tablewrite "calculations assuming lower fixed costs per village. Appendix Table " _n
file write tablewrite "\ref*{tab:irr_cs_components} breaks down the components used to construct these IRRs." _n
file write tablewrite "}" _n
file write tablewrite "\end{table}" _n

file close tablewrite

}

********************************************************************************
********************************************************************************

** Figure A15: Sampling distributions for expenditure-based ROI calculations
{

copy "${results}/expenditure_sampling_distributions.pdf" "${texfig}/expenditure_sampling_distributions.pdf", replace

   // MAKE FIGURE
file open tablewrite using "$texfig/figure_expenditure_sampling_dists.tex", write text replace
 
file write tablewrite "\begin{figure}[h!]\centering" _n
file write tablewrite "\caption{Sampling distributions used for expenditure-based ROI simulations}" _n
file write tablewrite "\label{fig:expenditure_sampling_dists}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "{\includegraphics[width=.66\textwidth, trim={0 15mm 0 15mm},clip]{${texfig_short}/expenditure_sampling_distributions.pdf}} " _n
file write tablewrite "\vspace{-4mm}" _n
file write tablewrite "\caption*{\scriptsize Note. --- This figure plots the distributions of annual consumption expenditures" _n
file write tablewrite "used to construct our ROI simulations in Table \ref*{tab:roi_expenditure}. " _n
file write tablewrite "For SHRUG estimates, we rescale the sampling distributions of our fuzzy RD point estimates " _n
file write tablewrite "in Column (1) of Table \ref*{tab:rd_fuzzy_shrug} by 10 (for hours of commercial power) " _n
file write tablewrite "and 2.6 (for nighttime brightness), while also deflating from 2011 rupees to 2010 rupees." _n
file write tablewrite "For NSS estimates, the sampling distributions of our IV point estimates " _n
file write tablewrite "in Columns (2)--(3) of Table \ref*{tab:nss_2sls} are already in 2010 rupees. " _n
file write tablewrite "We also rescale all distributions by 12, to convert from monthly to annual expenditures. " _n
file write tablewrite "}" _n
file write tablewrite "\end{figure}" _n

file close tablewrite
	
}

********************************************************************************
********************************************************************************

** Table A25: Sensitivities on expenditure-based ROI simulations
{

cap file close tablewrite
use "$results/roi_results_expenditure_bootstraps.dta", clear

local fc = "lo"
local g = "g"

count if ROI20_hours_5_`fc'_300`g'>0
local pos1_1 = string(r(N)/_N,"%9.3f")
count if ROI20_hours_10_`fc'_300`g'>0
local pos2_1 = string(r(N)/_N,"%9.3f")
count if ROI20_hours_15_`fc'_300`g'>0
local pos3_1 = string(r(N)/_N,"%9.3f")

count if ROI20_lights_5_`fc'_300`g'>0
local pos1_2 = string(r(N)/_N,"%9.3f")
count if ROI20_lights_10_`fc'_300`g'>0
local pos2_2 = string(r(N)/_N,"%9.3f")
count if ROI20_lights_15_`fc'_300`g'>0
local pos3_2 = string(r(N)/_N,"%9.3f")

count if ROI20_nss1_5_`fc'_1000`g'>0
local pos1_3 = string(r(N)/_N,"%9.3f")
count if ROI20_nss1_10_`fc'_1000`g'>0
local pos2_3 = string(r(N)/_N,"%9.3f")
count if ROI20_nss1_15_`fc'_1000`g'>0
local pos3_3 = string(r(N)/_N,"%9.3f")

count if ROI20_nss2_5_`fc'_2000`g'>0
local pos1_4 = string(r(N)/_N,"%9.3f")
count if ROI20_nss2_10_`fc'_2000`g'>0
local pos2_4 = string(r(N)/_N,"%9.3f")
count if ROI20_nss2_15_`fc'_2000`g'>0
local pos3_4 = string(r(N)/_N,"%9.3f")


local fc = "hi"
local g = ""

count if ROI20_hours_5_`fc'_300`g'>0
local pos4_1 = string(r(N)/_N,"%9.3f")
count if ROI20_hours_10_`fc'_300`g'>0
local pos5_1 = string(r(N)/_N,"%9.3f")
count if ROI20_hours_15_`fc'_300`g'>0
local pos6_1 = string(r(N)/_N,"%9.3f")

count if ROI20_lights_5_`fc'_300`g'>0
local pos4_2 = string(r(N)/_N,"%9.3f")
count if ROI20_lights_10_`fc'_300`g'>0
local pos5_2 = string(r(N)/_N,"%9.3f")
count if ROI20_lights_15_`fc'_300`g'>0
local pos6_2 = string(r(N)/_N,"%9.3f")

count if ROI20_nss1_5_`fc'_1000`g'>0
local pos4_3 = string(r(N)/_N,"%9.3f")
count if ROI20_nss1_10_`fc'_1000`g'>0
local pos5_3 = string(r(N)/_N,"%9.3f")
count if ROI20_nss1_15_`fc'_1000`g'>0
local pos6_3 = string(r(N)/_N,"%9.3f")

count if ROI20_nss2_5_`fc'_2000`g'>0
local pos4_4 = string(r(N)/_N,"%9.3f")
count if ROI20_nss2_10_`fc'_2000`g'>0
local pos5_4 = string(r(N)/_N,"%9.3f")
count if ROI20_nss2_15_`fc'_2000`g'>0
local pos6_4 = string(r(N)/_N,"%9.3f")



   // MAKE TABLE
file open tablewrite using "$textab/table_roi_expenditure_sens.tex", write text replace
 
file write tablewrite "\begin{table}[h!]\centering" _n
file write tablewrite "\caption{Sensitivity of expenditure-based return on investment simulations}" _n
file write tablewrite "\label{tab:roi_expenditure_sens}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\small" _n
file write tablewrite "\begin{tabular}{cccccccccc}" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "& \multicolumn{4}{c}{\$\Pr\big(\text{20-year ROI} > 0\big)\$, by village population} \\ " _n
file write tablewrite "[0.15em]" _n
file write tablewrite "& 300 & 300 & 1000 & 2000 \\" _n
file write tablewrite "\cline{2-5}" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "\multicolumn{1}{l}{\textbf{A.} \underline{Low fixed costs}} \\" _n
file write tablewrite "[0.15em]" _n
file write tablewrite "\$r = 0.05\$ & $`pos1_1'$ & $`pos1_2'$ & $`pos1_3'$ & $`pos1_4'$ \\" _n
file write tablewrite "\$r = 0.10\$ & $`pos2_1'$ & $`pos2_2'$ & $`pos2_3'$ & $`pos2_4'$ \\" _n
file write tablewrite "\$r = 0.15\$ & $`pos3_1'$ & $`pos3_2'$ & $`pos3_3'$ & $`pos3_4'$ \\" _n
file write tablewrite "[1.25em]" _n
file write tablewrite "\multicolumn{1}{l}{\textbf{B.} \underline{No population growth}} \\" _n
file write tablewrite "[0.15em]" _n
file write tablewrite "\$r = 0.05\$ & $`pos4_1'$ & $`pos4_2'$ & $`pos4_3'$ & $`pos4_4'$ \\" _n
file write tablewrite "\$r = 0.10\$ & $`pos5_1'$ & $`pos5_2'$ & $`pos5_3'$ & $`pos5_4'$ \\" _n
file write tablewrite "\$r = 0.15\$ & $`pos6_1'$ & $`pos6_2'$ & $`pos6_3'$ & $`pos6_4'$ \\" _n
file write tablewrite "[1em]" _n
file write tablewrite "\multicolumn{1}{l}{Expenditure/capita}    & SHRUG & SHRUG & NSS & NSS\\" _n
file write tablewrite "\multicolumn{1}{l}{Endog.\ variable} & Hours of power & Brightness & " _n
file write tablewrite "$ \mathbf{1}\big[\text{HH elec}>0\big] $  & $ \mathbf{1}\big[\text{HH elec}>0\big] $ \\" _n
file write tablewrite "\multicolumn{1}{l}{Instrument} & 300-person RD & 300-person RD & 1st-wave district  & 1st-wave district \\" _n
file write tablewrite "\multicolumn{1}{l}{Estimation sample} & RD bandwidth & RD bandwidth & Quintile 1 & Quintiles 2--5 \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\end{tabular}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\caption*{\scriptsize Note. --- " _n
file write tablewrite "This table presents two alternate versions of Table \ref*{tab:roi_expenditure}. " _n
file write tablewrite "Our preferred simulations in Table \ref*{tab:roi_expenditure} assume fixed costs " _n
file write tablewrite "of Rs 1.8 million per village, applying the \`\`high'' fixed cost norm " _n
file write tablewrite "from \citeauthor{banerjee_power_2014} (\citeyear{banerjee_power_2014}, p.\ 51). " _n
file write tablewrite "Panel A applies the same authors' \`\`low'' fixed cost norm of Rs 1.3 million per village. " _n
file write tablewrite "All ROI calculations apply variable costs of Rs 2,200 per household " _n
file write tablewrite "(\citeauthor{banerjee_power_2014} \citeyear{banerjee_power_2014}, p.\ 51). " _n
file write tablewrite "We inflate all costs from 2008 to 2010 rupees. " _n
file write tablewrite "Table 8 also applies the annual population growth rates from Panel G of Table \ref*{tab:irr_cs_components}. "
file write tablewrite "Panel B assumes zero population growth, which slightly reduces the ROIs relative to " _n
file write tablewrite "Table \ref*{tab:roi_expenditure}---since the undiscounted sum of per-capita benefits " _n
file write tablewrite "within each village is now constant over time (rather than increasing). " _n
file write tablewrite "}" _n
file write tablewrite "\end{table}" _n

file close tablewrite
	
}

********************************************************************************
********************************************************************************

** Table A26: IRR table using cosumer surplus estimates, but low fixed costs 
{
cap file close tablewrite
use "$results/roi_results_cs_irr.dta", clear
keep if hh_size==5
keep if round(elast,0.001)==0.62
keep if fc=="lo"

gen row = .
replace row = 1 if inlist(kwh_var,"q1","q25")		  & fc=="lo" & pop_growth==0 & kwh_growth_scenario=="0"    & exp_growth=="none"	
replace row = 2 if inlist(kwh_var,"q1","q25") 		  & fc=="lo" & pop_growth>0  & kwh_growth_scenario=="0"    & exp_growth=="none"	
replace row = 3 if inlist(kwh_var,"q1","q25") 		  & fc=="lo" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="none"	
replace row = 4 if inlist(kwh_var,"pop_exp_shares")   & fc=="lo" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="none"
replace row = 5 if inlist(kwh_var,"pop_exp_shares")   & fc=="lo" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="nss"	
replace row = 6 if inlist(kwh_var,"pop_exp_shares")   & fc=="lo" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="adhoc"	
replace row = 7 if inlist(kwh_var,"q1_hrs","q25_hrs") & fc=="lo" & pop_growth>0  & kwh_growth_scenario=="0.03" & exp_growth=="none"	
keep if row!=.
sort row pop
unique row pop
assert r(unique)==r(N)

	// round IRRs up
gen IRR = round(irr+.00001,0.01)	

	// create unified population growth variable
gen POP_GROWTH = "Yes" if pop_growth>0

	// create unified kwh_var 
gen KWH_VAR = kwh_var
replace KWH_VAR = "q1/q25" if inlist(kwh_var,"q1","q25")
replace KWH_VAR = "q1/q25 hrs" if inlist(kwh_var,"q1_hrs","q25_hrs")

	// reshape to construct table
reshape wide kwh_var kwh_mean pop_growth irr IRR, i(row) j(pop)
sort row

	// locals for table
forvalues r = 1/7 {

	if KWH_VAR[`r']=="q1/q25" {
	    local kwh`r' = "Q1 vs.\ Q25 splits"
	}
	else if KWH_VAR[`r']=="pop_exp_shares" {
	    local kwh`r' = "Expenditure quartile splits"
	}
	else if KWH_VAR[`r']=="q1/q25 hrs" {
	    local kwh`r' = "\$\begin{matrix}\text{Q1 vs.\ Q25 splits, districts} \\ \text{~~with high power quality}\end{matrix}\$"
	}

	if POP_GROWTH[`r']=="" & kwh_growth_scenario[`r']=="0" & exp_growth[`r']=="none" {
	    local scenario`r' = "No population or kWh growth"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0" & exp_growth[`r']=="none" {
	    local scenario`r' = "No kWh growth"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0.03" & exp_growth[`r']=="none" {
	    local scenario`r' = "Preferred"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0.03" & exp_growth[`r']=="nss" {
	    local scenario`r' = "NSS expenditure growth"
	}
	else if POP_GROWTH[`r']=="Yes" & kwh_growth_scenario[`r']=="0.03" & exp_growth[`r']=="adhoc" {
	    local scenario`r' = "3\% expenditure growth"
	}

	foreach pop in 300 1000 2000 {
	    local irr`pop'_`r' = string(IRR`pop'[`r']*100,"%9.0f") + "\%"
		if "`irr`pop'_`r''"=="-1\%" {
		    local irr`pop'_`r' = "--"
		}
	}
}	
	
	
   // MAKE TABLE
file open tablewrite using "$textab/table_irr_cs_fcost_lo.tex", write text replace
 
file write tablewrite "\begin{table}[h!]\centering" _n
file write tablewrite "\caption{Internal rate of return from electrification, assuming low fixed costs}" _n
file write tablewrite "\label{tab:irr_cs_fcost_lo}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\small" _n
file write tablewrite "\begin{tabular}{lccccccccc}" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "&&& \multicolumn{3}{c}{IRRs by village population} \\ " _n
file write tablewrite "\cline{4-6}" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "\multicolumn{1}{c}{\$\begin{matrix}\text{First-stage NSS estimates~~}\end{matrix}\$} " _n
file write tablewrite "& Scenario " _n 
file write tablewrite "&~& ~~300~~ & ~~1000~~ & ~~2000~~ \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite " " _n
file write tablewrite "`kwh1' & `scenario1' && `irr300_1' & `irr1000_1' & `irr2000_1' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh2' & `scenario2' && `irr300_2' & `irr1000_2' & `irr2000_2' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "\bf `kwh3' & \bf `scenario3' && \bf `irr300_3' & \bf `irr1000_3' & \bf `irr2000_3' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh4' & `scenario4' && `irr300_4' & `irr1000_4' & `irr2000_4' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh5' & `scenario5' && `irr300_5' & `irr1000_5' & `irr2000_5' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh6' & `scenario6' && `irr300_6' & `irr1000_6' & `irr2000_6' \\" _n
file write tablewrite "[0.4em]" _n
file write tablewrite "`kwh7' & `scenario7' && `irr300_7' & `irr1000_7' & `irr2000_7' \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\end{tabular}" _n
file write tablewrite "\vspace{-2mm}" _n
file write tablewrite "\caption*{\scriptsize Note. --- " _n
file write tablewrite "Calculations in this table are identical to those in Table \ref*{tab:irr_cs}, " _n
file write tablewrite "except that they assume lower fixed costs per electrified village.  " _n
file write tablewrite "Our preferred estimates in Table \ref*{tab:irr_cs} assume fixed costs " _n
file write tablewrite "of Rs 1.8 million per village, applying the \`\`high'' fixed cost norm " _n
file write tablewrite "from \citeauthor{banerjee_power_2014} (\citeyear{banerjee_power_2014}, p.\ 51). " _n
file write tablewrite "Here, we apply the same authors' \`\`low'' fixed cost norm of Rs 1.3 million per village. " _n
file write tablewrite "Both sets of IRR calculations apply variable costs of Rs 2,200 per household " _n
file write tablewrite "(\citeauthor{banerjee_power_2014} \citeyear{banerjee_power_2014}, p.\ 51). " _n
file write tablewrite "We inflate all costs from 2008 to 2010 rupees. " _n
file write tablewrite "In row 1, electrification is welfare-decreasing for 300-person villages " _n
file write tablewrite "even with a 0\% annual discount rate. " _n
file write tablewrite "In row 7, electrification is benefit-cost positive for 2000-person villages after 1 year. " _n
file write tablewrite "See notes under Tables \ref*{tab:irr_cs} and \ref*{tab:irr_cs_components} for further detail. " _n
file write tablewrite "}" _n
file write tablewrite "\end{table}" _n

file close tablewrite

}

********************************************************************************
********************************************************************************

** Table A28: Components that enter into IRR calculations
{
cap file close tablewrite
use "$results/roi_results_cs_full.dta", clear
keep if hh_size==5
keep if round(elast,0.001)==0.62
keep if disc==0
keep if t==1
gen cost_per_hh = hh_cost/n_hh
sum cost_per_hh
local cost_per_hh = string(r(mean),"%9.0fc")

	// Panel A: Q1/Q25 splits, year 1
foreach pop in 300 1000 2000 {
    
	// kWh per household
	sum q if inlist(kwh_var,"q1","q25") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local A1_`pop' = string(r(mean),"%9.1f")

	// consumer surplus per household
	sum cs_hh if inlist(kwh_var,"q1","q25") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local A2_`pop' = string(r(mean),"%9.0fc")

	// consumer surplus per village
	sum cs_vill if inlist(kwh_var,"q1","q25") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local A3_`pop' = string(r(mean),"%9.0fc")
	
}	

	// Panel B: Q1/Q25 splits, 10+ hours of power, year 1
foreach pop in 300 1000 2000 {
    
	// kWh per household
	sum q if inlist(kwh_var,"q1_hrs","q25_hrs") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local B1_`pop' = string(r(mean),"%9.1f")

	// consumer surplus per household
	sum cs_hh if inlist(kwh_var,"q1_hrs","q25_hrs") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local B2_`pop' = string(r(mean),"%9.0fc")

	// consumer surplus per village
	sum cs_vill if inlist(kwh_var,"q1_hrs","q25_hrs") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local B3_`pop' = string(r(mean),"%9.0fc")
	
}	

	// Panel C: Expenditure quartile splits, year 1
foreach pop in 300 1000 2000 {
    
	// kWh per household
	sum q if inlist(kwh_var,"pop_exp_shares") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local C1_`pop' = string(r(mean),"%9.1f")

	// consumer surplus per household
	sum cs_hh if inlist(kwh_var,"pop_exp_shares") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local C2_`pop' = string(r(mean),"%9.0fc")

	// consumer surplus per village
	sum cs_vill if inlist(kwh_var,"pop_exp_shares") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local C3_`pop' = string(r(mean),"%9.0fc")
	
}	

	// Panel G: Population growth rates, variable HH costs
foreach pop in 300 1000 2000 {
    
	// annual population growth
	sum pop_growth if inlist(kwh_var,"q1","q25") & pop_growth>0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local G1_`pop' = string(r(mean)*100,"%9.2f") + "\%"

	// consumer surplus per household
	sum hh_costs if inlist(kwh_var,"q1_hrs","q25_hrs") & pop_growth==0 & kwh_growth_scenario=="0" & exp_growth=="none" & pop==`pop'
	assert r(N)==1
	local G3_`pop' = string(r(mean),"%9.0fc")

}	

***

use "$panel/panel_dataset_dd_nss_uncollapsed.dta", clear
global pop = "300 1000 2000" // considering villages of 3 population sizes
global exp_growth = "0.03" // ad hoc, following Lee, Miguel, and Wolfram (2020b)

	// make weights representative at the national level (rather than district level)
gen weight_pop = weight_normalized * tot_p_dist
	
	// mean kWh per month
sum elec_quantity if year==2010 & elec_q_yn>0 [aw=weight_pop], detail
global kwh_mean = string(r(mean),"%9.1f")

	// make expenditure quartiles
sum mth_pc_expE1 [aw=weight_pop], detail
gen exp_quartile = .
replace exp_quartile = 1 if mth_pc_expE1<=r(p25)
replace exp_quartile = 2 if mth_pc_expE1<=r(p50) & exp_quartile==.
replace exp_quartile = 3 if mth_pc_expE1<=r(p75) & exp_quartile==.
replace exp_quartile = 4 if exp_quartile==.
global exp_max1_table = string(r(p25),"%9.0fc")
global exp_max2_table = string(r(p50),"%9.0fc")
global exp_max3_table = string(r(p75),"%9.0fc")
global exp_max4_table = string(r(max),"%9.0fc")
tab exp_quartile, gen(expQ)

	// shares by expenditure quartiles, by village size
foreach y in 2005 2010 {
	foreach pop in $pop {
		foreach exp in 1 2 3 4 {
			sum expQ`exp' [aw=weight_pop] if inrange(frame_population,`pop'-50,`pop'+50) & year==`y'
			global share_exp`exp'_`pop'_y`y' = r(mean)
		}
	}
}	

	// expenditure growth rates, as annualized percentage point increases in the share of households in each quartile
foreach pop in $pop {
	foreach exp in 1 2 3 4 {
		global delta_exp`exp'_`pop' = (${share_exp`exp'_`pop'_y2010} - ${share_exp`exp'_`pop'_y2005})/5
	}
	assert abs(${delta_exp1_`pop'} + ${delta_exp2_`pop'} + ${delta_exp3_`pop'} + ${delta_exp4_`pop'})<1e-10
}

	// construct kWh from just summary stats by village size
foreach y in 2005 2010 {
	foreach pop in $pop {
		sum elec_quantity [aw=weight_pop] if elec_q_yn>0 & inrange(frame_population,`pop'-50,`pop'+50) & year==`y'
		global kwh_mean_`pop'_y`y' = r(mean)
	}
}	

	// kWh growth rates, annualized from summary stats within each village size
foreach pop in $pop {
	global delta_kwh_`pop' = (${kwh_mean_`pop'_y2010}/${kwh_mean_`pop'_y2005})^(1/5)-1
}
	
	// impose ad hoc 3% expenditure growth, create hypothetical 2011 dummies for expenditure quartiles (w/o quartile cut points)
gen exp_2011 = mth_pc_expE1*(1 + $exp_growth )
sum mth_pc_expE1 [aw=weight_pop], detail
gen exp_2011_quartile = .
replace exp_2011_quartile = 1 if year==2010 & exp_2011<=r(p25)
replace exp_2011_quartile = 2 if year==2010 & exp_2011<=r(p50) & exp_2011_quartile==.
replace exp_2011_quartile = 3 if year==2010 & exp_2011<=r(p75) & exp_2011_quartile==.
replace exp_2011_quartile = 4 if year==2010 & exp_2011_quartile==.
tab exp_2011_quartile if year==2010, gen(exp2011Q)

	// shares by hypothetical 2011 expenditure quartiles, by village size
foreach pop in $pop {
	foreach exp in 1 2 3 4 {
		sum exp2011Q`exp' [aw=weight_pop] if inrange(frame_population,`pop'-50,`pop'+50) & year==2010
		global share_exp`exp'_`pop'_y2011 = r(mean)
	}
}	

	// 3% annualized expenditure growth rate, as percentage point increases in the share of households in each quartile
foreach pop in $pop {
	foreach exp in 1 2 3 4 {
		global delta_exp`exp'_`pop'_3pct = ${share_exp`exp'_`pop'_y2011} - ${share_exp`exp'_`pop'_y2010}
	}
}

	// Panel D: 2010 expenditure quartile shares
foreach pop in 300 1000 2000 {
	foreach exp in 1 2 3 4 {
	    local D`exp'_`pop' = string(${share_exp`exp'_`pop'_y2010},"%9.3f")
	}	
}	

	// Panel E: 2010 expenditure quartile graduation rates, given NSS growth expenditure growth rate
foreach pop in 300 1000 2000 {
	foreach exp in 1 2 3 4 {
	    if ${delta_exp`exp'_`pop'} >0 {
			local E`exp'_`pop' = "\$ +" + string(${delta_exp`exp'_`pop'},"%9.3f") + " \$"
			di "`E`exp'_`pop''"
		}
	    else {
			local E`exp'_`pop' = "\$ " + string(${delta_exp`exp'_`pop'},"%9.3f") + " \$"
			di "`E`exp'_`pop''"
		}
	}	
}	

	// Panel F: 2010 expenditure quartile graduation rates, assuming ad hoc 3% expenditure growth rate
foreach pop in 300 1000 2000 {
	foreach exp in 1 2 3 4 {
	    if ${delta_exp`exp'_`pop'_3pct} >0 {
			local F`exp'_`pop' = "\$ +" + string(${delta_exp`exp'_`pop'_3pct},"%9.3f") + " \$"
		}
	    else {
			local F`exp'_`pop' = "\$ " + string(${delta_exp`exp'_`pop'_3pct},"%9.3f") + " \$"
		}
	}	
}	

	// Panel G: NSS-implied kWh and expenditure growth rates
foreach pop in 300 1000 2000 {
    local G2_`pop' = string(${delta_kwh_`pop'}*100,"%9.2f") + "\%"
}	

	
	
   // MAKE TABLE
file open tablewrite using "$textab/table_irr_cs_components.tex", write text replace
 
file write tablewrite "\begin{table}[h!]\centering" _n
file write tablewrite "\caption{Components used to calculate internal rates of return from electrification}" _n
file write tablewrite "\label{tab:irr_cs_components}" _n
file write tablewrite "\vspace{-3mm}" _n
file write tablewrite "\small" _n
file write tablewrite "\centerline{" _n
file write tablewrite "\begin{tabular}{lccccccccc}" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "&& \multicolumn{3}{c}{Village population} \\ " _n
file write tablewrite "\cline{3-5}" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "&~& ~~\,300\,~~ & ~~\,1000\,~~ & ~~\,2000\,~~ \\" _n
file write tablewrite "\hline" _n
file write tablewrite "\\" _n
file write tablewrite "\vspace{-8mm}" _n
file write tablewrite "\\" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{A.} \underline{Year 1 consumption and surplus, Q1 vs.\ Q25 splits}} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~kWh/month per newly electrified HH 	        && `A1_300' & `A1_1000' & `A1_2000' \\ " _n
file write tablewrite "~~~~CS per newly electrified HH (Rs/year)        && `A2_300' & `A2_1000' & `A2_2000' \\ " _n
file write tablewrite "~~~~CS summed across all HH in village (Rs/year) && `A3_300' & `A3_1000' & `A3_2000' \\ " _n
file write tablewrite "[0.8em]" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{B.} \underline{Year 1 consumption and surplus, Q1 vs.\ Q25 high power quality splits}} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~kWh/month per newly electrified HH 	        && `B1_300' & `B1_1000' & `B1_2000' \\ " _n
file write tablewrite "~~~~CS per newly electrified HH (Rs/year)        && `B2_300' & `B2_1000' & `B2_2000' \\ " _n
file write tablewrite "~~~~CS summed across all HH in village (Rs/year) && `B3_300' & `B3_1000' & `B3_2000' \\ " _n
file write tablewrite "[0.8em]" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{C.} \underline{Year 1 consumption and surplus, expenditure quartile splits}} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~kWh/month per newly electrified HH 	        && `C1_300' & `C1_1000' & `C1_2000' \\ " _n
file write tablewrite "~~~~CS per newly electrified HH (Rs/year)        && `C2_300' & `C2_1000' & `C2_2000' \\ " _n
file write tablewrite "~~~~CS summed across all HH in village (Rs/year) && `C3_300' & `C3_1000' & `C3_2000' \\ " _n
file write tablewrite "[.8em]" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{D.} \underline{Share of households in each expenditure quartile (2010 NSS) }} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~Share of HH in quartile 1, \$\big[0~,~$exp_max1_table\big]\$ Rs/month               && `D1_300' & `D1_1000' & `D1_2000' \\ " _n
file write tablewrite "~~~~Share of HH in quartile 2, \$\big($exp_max1_table~,~$exp_max2_table\big]\$ Rs/month && `D2_300' & `D2_1000' & `D2_2000' \\ " _n
file write tablewrite "~~~~Share of HH in quartile 3, \$\big($exp_max2_table~,~$exp_max3_table\big]\$ Rs/month && `D3_300' & `D3_1000' & `D3_2000' \\ " _n
file write tablewrite "~~~~Share of HH in quartile 4, \$\big($exp_max3_table~,~$exp_max4_table\big]\$ Rs/month && `D4_300' & `D4_1000' & `D4_2000' \\ " _n
file write tablewrite "[0.8em]" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{E.} \underline{Observed changes in expenditure shares (2005 \& 2010 NSS) }} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 1 && `E1_300' & `E1_1000' & `E1_2000' \\ " _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 2 && `E2_300' & `E2_1000' & `E2_2000' \\ " _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 3 && `E3_300' & `E3_1000' & `E3_2000' \\ " _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 4 && `E4_300' & `E4_1000' & `E4_2000' \\ " _n
file write tablewrite "[0.8em]" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{F.} \underline{Changes in expenditure shares, under 3\% annual expenditure growth}} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 1 && `F1_300' & `F1_1000' & `F1_2000' \\ " _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 2 && `F2_300' & `F2_1000' & `F2_2000' \\ " _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 3 && `F3_300' & `F3_1000' & `F3_2000' \\ " _n
file write tablewrite "~~~~Annualized change in share of HH in quartile 4 && `F4_300' & `F4_1000' & `F4_2000' \\ " _n
file write tablewrite "[0.8em]" _n
file write tablewrite "\multicolumn{2}{l}{\textbf{G.} \underline{Additional assumptions and summary statistics}} \\ " _n
file write tablewrite "[0.1em]" _n
file write tablewrite "~~~~Annualized population growth rate (2001 \& 2011 Census)             && `G1_300' & `G1_1000' & `G1_2000' \\ " _n
file write tablewrite "~~~~Annualized growth rate in kWh per electrified HH (2005 \& 2010 NSS) && `G2_300' & `G2_1000' & `G2_2000' \\ " _n
file write tablewrite "~~~~Total variable costs: Rs `cost_per_hh' per household                && `G3_300' & `G3_1000' & `G3_2000' \\ " _n
file write tablewrite "\hline" _n
file write tablewrite "\end{tabular}" _n
file write tablewrite "}" _n
file write tablewrite "\vspace{-3.5mm}" _n
file write tablewrite "\captionsetup{width=1.05\textwidth}"
file write tablewrite "\caption*{\scriptsize Note. --- " _n
file write tablewrite "Panels A--C report kWh per electrified household used in Table \ref*{tab:irr_cs}, for the initial year post-electrification. "
file write tablewrite "We calculate consumer surplus assuming linear electricity demand, a demand elasticity of 0.62 (\textcite{burgess_demand_2020}), "
file write tablewrite "a retail electricity price of Rs 2.64 per kWh (the median price in the 2010 NSS), and 5 people per household. "
file write tablewrite "For rows 1--3 of Table \ref*{tab:irr_cs}, Panel A divides Column (4) by Column (2) in Tables " _n
file write tablewrite "\ref{tab:nss_first_stage_q1}--\ref{tab:nss_first_stage_q25} (using Q1 estimates for 300- and 1000-person villages, " _n
file write tablewrite "and Q25 estimates for 2000-person villages). " _n
file write tablewrite "For row 7 of Table \ref*{tab:irr_cs}, Panel B uses the analogous first-stage estimates from Table \ref{tab:nss_fs_hours}. " _n
file write tablewrite "For rows 4--6 of Table \ref*{tab:irr_cs}, Panel C takes the inner product of expenditure-quartile-specific kWh per household " _n
file write tablewrite " (ratios of coefficients from Table \ref{tab:nss_first_stage_by_exp_quartile}) and village-size-specific expenditure " _n
file write tablewrite "quartile shares (reported in Panel D). " _n
file write tablewrite "For row 5 of Table \ref*{tab:irr_cs}, we use the observed annualized shifts in expenditure quartile shares " _n
file write tablewrite "(reported in Panel E) translate year-on-year growth in expenditures into increased electricity consumption, " _n
file write tablewrite "by recalculating the inner product with updated expenditure quartile shares for each year post-electrification. " _n
file write tablewrite "For row 6 of Table \ref*{tab:irr_cs}, we do the same using the annualized shifts in expenditure quartile shares " _n
file write tablewrite "implied by 3\% annual growth in expenditure (following \textcite{lee_experimental_2020}; reported in Panel F). " _n
file write tablewrite "Rows 2--7 of Table \ref*{tab:irr_cs} impose annual population growth rates for each village size, as implied by the " _n
file write tablewrite "2001 and 2011 Censuses (reported in Panel G). " _n
file write tablewrite "Rows 3--7 of Table \ref*{tab:irr_cs} impose 3\% annual growth in kWh, which exceeds the annualized " _n
file write tablewrite "growth rates implied by the 2005 and 2010 NSS (reported in Panel G; in rows 5--6 of Table \ref*{tab:irr_cs}, " _n
file write tablewrite "this 3\% kWh growth in on top of expenditure-driven increases in kWh). " _n
file write tablewrite "All IRR calculations include variable costs of `cost_per_hh' per household (reported in Panel G), inflating " _n
file write tablewrite "Rs 2,200 per household  (\citeauthor{banerjee_power_2014} \citeyear{banerjee_power_2014}, p.\ 51) " _n
file write tablewrite "from 2008 to 2010 rupees. Expenditures and consumer surplus are also in 2010 rupees. " _n
file write tablewrite "NSS summary statistics impose nationally representative weights, inflating NSS weights by each " _n
file write tablewrite "district's rural population. The average NSS household with positive electricity consumption " _n
file write tablewrite "consumed $kwh_mean kWh per month." _n
file write tablewrite "Village-size-specific summary statistics use villages with populations of " _n
file write tablewrite "[250, 350], [950, 1050], and [1950, 2050], respectively. " _n
file write tablewrite "}" _n
file write tablewrite "\end{table}" _n

file close tablewrite

}

********************************************************************************
********************************************************************************



